﻿using System;

namespace HobSoft.SoccerBet2014.Common.Errors
{
    public static class Error
    {
        public static void ThrowInvalidOperation(this ValidResult result)
        {
            if (result.Result)
                throw new InvalidOperationException();
        }

        public static void ThrowInvalidOperation(this ValidResult result, string message)
        {
            if (result.Result)
                throw new InvalidOperationException(message);
        }

        public static void ThrowInvalidOperation(this ValidResult result, string format, params object[] args)
        {
            if (result.Result)
                throw new InvalidOperationException(string.Format(format, args));
        }

        public static void ThrowInvalidOperation()
        {
            throw new InvalidOperationException();
        }

        public static void ThrowInvalidOperation(string message)
        {
            throw new InvalidOperationException(message);
        }

        public static void ThrowInvalidOperation(string format, params object[] args)
        {
            throw new InvalidOperationException(string.Format(format, args));
        }

        public static void ThrowNull(this ValidResult result)
        {
            if (result.Result)
                throw new ArgumentNullException();
        }

        public static void ThrowNull(this ValidResult result, string paramName)
        {
            if (result.Result)
                throw new ArgumentNullException(paramName);
        }

        public static void ThrowNull(this ValidResult result, string paramName, string message)
        {
            if (result.Result)
                throw new ArgumentNullException(paramName, message);
        }

        public static void ThrowNull()
        {
            throw new ArgumentNullException();
        }

        public static void ThrowNull(string paramName)
        {
            throw new ArgumentNullException(paramName);
        }

        public static void ThrowNull(string paramName, string message)
        {
            throw new ArgumentNullException(paramName, message);
        }

        public static void ThrowNotSupported(this ValidResult result)
        {
            if (result.Result)
                throw new NotSupportedException();
        }

        public static void ThrowNotSupported(this ValidResult result, string message)
        {
            if (result.Result)
                throw new NotSupportedException(message);
        }

        public static void ThrowNotSupported()
        {
            throw new NotSupportedException();
        }

        public static void ThrowNotSupported(string message)
        {
            throw new NotSupportedException(message);
        }
    }
}
